#ifndef SMOKESENSOR_H
#define SMOKESENSOR_H

#include "TableWidgetForm.h"

struct SmokeConnectStr
{
    QString name;
    QString type;

    // 获取结构体成员名的字符串
    QString toFieldNames() const {
        return QString("name,type");
    }

    // 获取结构体成员名的字符串
    QStringList toFieldTypes() const {
        QStringList _list;
        _list << typeid(name).name();
        _list << typeid(type).name();
        return _list;
    }
};

struct SmokeSensorstruct
{
    int id;
    QString name;
    int alarm;
    int phyid;
    int board_id;
    int port;

    // 获取结构体成员名的字符串
    QString toFieldNames() const {
        return QString("name,alarm,phyid,board_id,port");
    }

    // 获取结构体成员名的字符串
    QStringList toFieldTypes() const {
        QStringList _list;
        _list << typeid(name).name();
        _list << typeid(alarm).name();
        _list << typeid(phyid).name();
        _list << typeid(board_id).name();
        _list << typeid(port).name();
        return _list;
    }
};

class SmokeSensor
{
public:
    SmokeSensor();

    //初始化UI
    static void InitUI(const QString& fileName, QList<QPair<QWidget *, QString>>& widgets, QMap<int, QList<TableWidgetForm*>>& m_pTableWidgetFormMap);

    //保存
    static bool SaveUI(const QString& fileName, const QMap<int, QList<TableWidgetForm*>>& m_pTableWidgetFormMap);

    //解析
    static void Analysis(const QString& path, SmokeConnectStr &_SmokeConnectStr, QList<QList<SmokeSensorstruct>>& _SmokeSensorstructList);

    //保存
    static bool SaveXml(const QString& path, const SmokeConnectStr &_SmokeConnectStr, const QList<QList<SmokeSensorstruct>>& _SmokeSensorstructList);
};

#endif // SMOKESENSOR_H
